#include "StdAfx.h"
#include "AltiumCircuitHarnessEntry.h"


CAltiumCircuitHarnessEntry::CAltiumCircuitHarnessEntry(void)
{
	m_szName = _T("");

	m_dblPosition = 0.0;

	m_eSide = SIDE_LEFT;

	m_szHarnessType = _T("");

	m_eTextStyle =  TEXT_STYLE_PREFIX;

	m_dblFontColor[0] = 0.0;
	m_dblFontColor[1] = 0.0;
	m_dblFontColor[2] = 0.0;

	m_circuitFont = NULL;
}

CAltiumCircuitHarnessEntry::CAltiumCircuitHarnessEntry( const CAltiumCircuitHarnessEntry *pEntityObj )
	:CCircuitUnit(pEntityObj)
{
	m_szName = pEntityObj->GetName();

	m_dblPosition = pEntityObj->GetPosition();

	m_szHarnessType = pEntityObj->GetHarnessType();

	m_eTextStyle =  pEntityObj->GetTextStyle();

	m_dblFontColor[0] = pEntityObj->GetFontColorR();
	m_dblFontColor[1] = pEntityObj->GetFontColorG();
	m_dblFontColor[2] = pEntityObj->GetFontColorB();

	m_circuitFont = pEntityObj->GetFont();
}

CAltiumCircuitHarnessEntry::CAltiumCircuitHarnessEntry( CICircuit *pParentEnt )
	: CCircuitUnit(pParentEnt)
{
	m_szName = _T("");

	m_dblPosition = 0.0;

	m_szHarnessType = _T("");

	m_eTextStyle =  TEXT_STYLE_PREFIX;

	m_dblFontColor[0] = 0.0;
	m_dblFontColor[1] = 0.0;
	m_dblFontColor[2] = 0.0;

	m_circuitFont = NULL;
}


CAltiumCircuitHarnessEntry::~CAltiumCircuitHarnessEntry(void)
{
	if (m_circuitFont)
	{
		delete m_circuitFont;
	}
}

void CAltiumCircuitHarnessEntry::Serialize( CArchive & ar )
{
	if (ar.IsStoring())
	{
		CObj::WriteString(ar,m_szName);
		ar<<m_dblPosition;
		CObj::WriteString(ar,m_szHarnessType);
		ar<<m_eTextStyle;
		ar<<m_dblFontColor[0];
		ar<<m_dblFontColor[1];
		ar<<m_dblFontColor[2];
		m_circuitFont->Serialize(ar);
	}
	else
	{
		CObj::ReadString(ar,m_szName);
		ar>>m_dblPosition;
		CObj::ReadString(ar,m_szHarnessType);
		int nTextStyle(0);
		ar>>nTextStyle;
		m_eTextStyle = (eTextStyle)nTextStyle;
		ar>>m_dblFontColor[0];
		ar>>m_dblFontColor[1];
		ar>>m_dblFontColor[2];
		m_circuitFont = new CCircuitFont();
		m_circuitFont->Serialize(ar);
	}
	CCircuitUnit::Serialize(ar);

}

CObj * CAltiumCircuitHarnessEntry::Clone() const
{
	return new CAltiumCircuitHarnessEntry(this);
}

CDisplayObj * CAltiumCircuitHarnessEntry::CreateDisplayObj( long lLayerId )
{
	CAltiumCircuitHarnessEntryDisObj* pEntryDis = new CAltiumCircuitHarnessEntryDisObj(this);
	pEntryDis->SetLayerId(lLayerId);
	return pEntryDis;
}

void CAltiumCircuitHarnessEntry::CalcBox()
{
	 
}

eCircuitUnitEntType CAltiumCircuitHarnessEntry::GetUnitType() const
{
	return ALTIUM_CIRCUIT_SHEET_ENTRY;
}


double CAltiumCircuitHarnessEntry::GetFontColorR() const
{
	return m_dblFontColor[0];
}

double CAltiumCircuitHarnessEntry::GetFontColorG() const
{
	return m_dblFontColor[1];
}

double CAltiumCircuitHarnessEntry::GetFontColorB() const
{
	return m_dblFontColor[2];
}

void CAltiumCircuitHarnessEntry::SetFontColorR( double colR)
{
	m_dblFontColor[0] = colR;
}

void CAltiumCircuitHarnessEntry::SetFontColorG( double colG)
{
	m_dblFontColor[1] = colG;
}

void CAltiumCircuitHarnessEntry::SetFontColorB( double colB)
{
	m_dblFontColor[2] = colB;
}

